<?php
defined('IN_TS') or die('Access Denied.');


		$start	= intval($_POST['start']);
		$end	= trim($_POST['end']);
		
		$start = 20;
		$end = 20;
		
	$sql = "select * from ".dbprefix."group_topics where isphoto='1' and isshow='0' order by istop desc,uptime desc limit ".$start.",".$end;
	
	$arrTTopicsall = $db->fetch_all_assoc($sql);
	
	
	if( is_array($arrTTopicsall)){
			$i=0;
		foreach($arrTTopicsall as $key){
		$arrTTopics1[] = $arrTTopicsall[$i];
			$i=$i+4;
			}
		$arrTTopics1 =array_filter($arrTTopics1);
		if( is_array($arrTTopics1)){
		foreach($arrTTopics1 as $key=>$item){
			$arrTTopic1[] = $item;
			$arrTTopic1[$key]['user'] = aac('user',$db)->getSimpleUser($item['userid']);
			$thumbimg=$db->once_fetch_assoc("select * from ".dbprefix."thumb_topic_index where topicid=".$item['topicid']."");
			if ($thumbimg){
			$arrTTopic1[$key]['thumb'] =$thumbimg['indeximgurl'];
			}else{
			$random = random(14);
			$imgurl="cache/thumb/index/".$random."w200.jpg";
			$oldimgurl = $new['home']->getfristimg($item['content']);
			$arr_img=getimagesize($oldimgurl);
			$resizeimage = new resizeimage( "$oldimgurl", "200", "", "0", "$imgurl" );
			$tid=$item['topicid'];
			$db->query("INSERT INTO ".dbprefix."thumb_topic_index (`topicid`,`indeximgurl`) VALUES ('$tid','$imgurl')");
			$arrTTopic1[$key]['thumb'] =$imgurl;
			}
			$thumbimg=$db->once_fetch_assoc("select * from ".dbprefix."thumb_topic_topic where topicid=".$item['topicid']."");
			if ($thumbimg&&strstr($thumbimg['indeximgurl'],'t100x100')){
			}else{
			$random = random(14);
			$imgurl="cache/thumb/index/".$random."t100x100.jpg";
			$oldimgurl = $new['home']->getfristimg($item['content']);
			$arr_img=getimagesize($oldimgurl);
			$resizeimage = new resizeimage( "$oldimgurl", "100", "100", "1", "$imgurl" );
			$tid=$item['topicid'];
			$db->query("INSERT INTO ".dbprefix."thumb_topic_topic (`topicid`,`indeximgurl`) VALUES ('$tid','$imgurl')");
			}
		}
	}
	}
				$moretopic =json_encode($arrTTopic1);
				echo $moretopic;